<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initialscale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
 <div id="app">
     <form action="xxxx" v-on:submit.pervent="onSubmit()">
         <Input type="text" id="username" v-model="user.username"></Input>
         <button type="submit">保存</button>
     </form>
 </div>
 <script src="vue.min.js"></script>
 <script>
    new Vue({
    el: '#app',
    data: {
        user: {}
    },
    methods: {
        onSubmit() {
            if(this.user.username){
                console.log("登陆成功")
            }else{
                alert("请输入用户名")
            }
        }
    }
    })
 </script>
</body>

</html>